45 #define SLAVE_ADDRESS 0x48
77 WDT_A_hold(WDT_A_BASE);
80 UCS_setExternalClockSource(32768, 0);
84 GPIO_setAsPeripheralModuleFunctionInputPin(
90 EUSCI_B_I2C_initMasterParam
param = {0};
91 param.selectClockSource = EUSCI_B_I2C_CLOCKSOURCE_SMCLK;
92 param.i2cClk = UCS_getSMCLK();
93 param.dataRate = EUSCI_B_I2C_SET_DATA_RATE_400KBPS;
95 param.autoSTOPGeneration = EUSCI_B_I2C_SEND_STOP_AUTOMATICALLY_ON_BYTECOUNT_THRESHOLD;
96 EUSCI_B_I2C_initMaster(EUSCI_B0_BASE, &
param);
99 EUSCI_B_I2C_setSlaveAddress(EUSCI_B0_BASE,
104 EUSCI_B_I2C_setMode(EUSCI_B0_BASE,
105 EUSCI_B_I2C_RECEIVE_MODE
109 EUSCI_B_I2C_enable(EUSCI_B0_BASE);
111 EUSCI_B_I2C_clearInterrupt(EUSCI_B0_BASE,
112 EUSCI_B_I2C_RECEIVE_INTERRUPT0 +
113 EUSCI_B_I2C_BYTE_COUNTER_INTERRUPT +
114 EUSCI_B_I2C_NAK_INTERRUPT
118 EUSCI_B_I2C_enableInterrupt(EUSCI_B0_BASE,
119 EUSCI_B_I2C_RECEIVE_INTERRUPT0 +
120 EUSCI_B_I2C_BYTE_COUNTER_INTERRUPT +
121 EUSCI_B_I2C_NAK_INTERRUPT
134 while (EUSCI_B_I2C_SENDING_STOP ==
135 EUSCI_B_I2C_masterIsStopSent(EUSCI_B0_BASE));
137 EUSCI_B_I2C_masterReceiveStart(EUSCI_B0_BASE);
140 __bis_SR_register(CPUOFF+GIE);
144 #if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
145 #pragma vector=USCI_B0_VECTOR
147 #elif defined(__GNUC__)
148 __attribute__((interrupt(USCI_B0_VECTOR)))
152 static uint8_t count = 0;
153 switch(__even_in_range(UCB0IV, USCI_I2C_UCBIT9IFG))
157 case USCI_I2C_UCALIFG:
159 case USCI_I2C_UCNACKIFG:
160 EUSCI_B_I2C_masterReceiveStart(EUSCI_B0_BASE);
162 case USCI_I2C_UCSTTIFG:
164 case USCI_I2C_UCSTPIFG:
166 case USCI_I2C_UCRXIFG3:
168 case USCI_I2C_UCTXIFG3:
170 case USCI_I2C_UCRXIFG2:
172 case USCI_I2C_UCTXIFG2:
174 case USCI_I2C_UCRXIFG1:
176 case USCI_I2C_UCTXIFG1:
178 case USCI_I2C_UCRXIFG0:
180 RXData = EUSCI_B_I2C_masterReceiveSingle(
188 case USCI_I2C_UCTXIFG0:
190 case USCI_I2C_UCBCNTIFG:
191 GPIO_toggleOutputOnPin(
196 case USCI_I2C_UCCLTOIFG:
198 case USCI_I2C_UCBIT9IFG:
MPU_initThreeSegmentsParam param
__bic_SR_register_on_exit(LPM3_bits|GIE)